#include <cstring>
#include <cstdio>

int dem[401];
int t,n,a,b;

int main()
{
	freopen("test.in","r",stdin);
	scanf("%d",&t);
	while(t--)
	{
		memset(dem,0,sizeof(dem));
		scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			scanf("%d%d",&a,&b);
			if(a>b){int p=a;a=b;b=p;}
			if(a%2==1)a++;
			if(b%2==1)b++;
			a/=2;b/=2;
			dem[a] += 1;
			dem[b+1] -= 1;
		}
		int max=0;
		for(int i = 1; i<=200;i++)
		{
			dem[i] += dem[i-1];	
			if(max < dem[i])max = dem[i];
		}
		printf("%d\n",max*10);
	}

	return 0;
}
